// import {
//   CONFIG
// } from './config';
// import {
//   PaddleJS
// } from './utils/paddleRegister';
let getUserProfile = require("./utils/login").getUserProfile;

App({
  globalData: {
    userInfo: {},
    userSession: {},
    isLogin: false
  },
  onLaunch() {
    // 展示本地存储能力
    const userInfo = wx.getStorageSync('userInfo')
    console.log(userInfo)
    if (userInfo) {
      this.globalData.userInfo = userInfo
      this.globalData.userSession = wx.getStorageSync('userSession')
      this.globalData.isLogin = true
    } else {
      getUserProfile()
    }

  },
  watchGlobalData(watchProperty, watchCallback) {
    const globalData = this.globalData;
    // 通过拦截全局对象属性set get 方法 插入监听全局变量的回调
    Object.defineProperty(globalData, watchProperty, {
      configurable: true,
      enumerable: true,
      set: value => {
        this.globalData['_' + watchProperty] = value;
        // callback
        watchCallback(value);
      },
      get: () => {
        return this.globalData['_' + watchProperty];
      }
    });
  }

})